package com.作业.Day4;

import java.util.ArrayList;
import java.util.Scanner;

public class Homework7 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        CustomerBiz customerBiz = new CustomerBiz();
        while(true){
            System.out.print("请输入客户的姓名:");
            String name = scanner.next();
            customerBiz.addName(name);
            System.out.print("继续输入吗？(y/n)");
            String next = scanner.next();
            if(next.equals("y"))
                continue;
            System.out.println("*********************");
            System.out.println("客户姓名列表:");
            System.out.println("*********************");
            customerBiz.showNames();
        }

    }
}
class CustomerBiz{
    ArrayList<String> nameList =new ArrayList<>();//用户名
   void  addName(String name){
        nameList.add(name);
    }
    void showNames(){

        for (String name : nameList) {
            System.out.print(name+" ");
        }
    }
    /**
     * 查找
     */
    void selectName(String oleName,String newName){
        int i=0;
        for (String name1 : nameList) {
            if(oleName.equals(name1)){
                   nameList.set(i,newName);
                System.out.println("找到并修改成功");
                showNames();
                return;
            }

            i++;
        }
        System.out.println("没有该客户姓名");
        showNames();
    }
}
